import { Config } from './flow-design';

const svgU = 'icon_module/svg/';

//规则基础
export const rule_bases: Array<Config> = [
	{
		type: 'StartNode',
		text: '开始',
		content: '一般作为启动组件，启动时创建一个初始化数据，执行后续所有流程节点',
		icon: svgU + 'start.svg',
	},
	{
		type: 'StopNode',
		text: '结束',
		content: '所有流程结束。',
		icon: svgU + 'end.svg',
	},
	{
		type: 'ApprovalNode',
		text: '审批任务',
		content: '角色，部门，人员审批。',
		icon: svgU + 'approval.svg',
	},
];

//网关节点
export const rule_gateway: Array<Config> = [
	{
		type: 'GatewayParallelNode',
		text: '并行网关',
		content: '并行网关不会解析流条件。 即使顺序流中定义了流条件，也会被忽略。',
		icon: svgU + 'parallel.svg',
	},
	{
		type: 'GatewayXorNode',
		text: '排他网关',
		content: '排他网关就好像一个人走到了一个岔路口，只能选择一条路前进，至于选择哪条路由顺序流的条件决定',
		icon: svgU + 'xor.svg',
	},
	/*  {
        type: "GatewayOrNode",
        text: "包容网关",
        content: "包含网关就好像是互斥网关和并行网关的结合体，即可以当排他网关使用，也可以当并行网关使用,可以在外出顺序流上定义流条件，包含网关会解析它们。包含网关可以选择多于一条顺序流，这和并行网关一样",
        icon: svgU+'or.svg',
    }*/
];

// 服务节点
export const rule_server: Array<Config> = [
	{
		type: 'EmailNode',
		text: '发邮件',
		content: '数据发送到Email',
		icon: svgU + 'email.svg',
	},
	{
		type: 'DingNode',
		text: '钉钉',
		content: '数据发送到钉钉机器人',
		icon: svgU + 'ding.svg',
	},
	{
		type: 'WechatNode',
		text: '企业微信',
		content: '数据发送到企业微信机器人',
		icon: svgU + 'wechat.svg',
	},
	{
		type: 'ExecNode',
		text: '脚本执行',
		content: '执行特定的后端脚本',
		icon: svgU + 'exec.svg',
	},
];

export const rule_other: Array<Config> = [
	{
		type: 'InputNode',
		text: '输入',
		content: '一般作为启动组件，启动时创建一个初始化数据，执行后续所有流程节点',
		icon: svgU + 'start.svg',
		formList: [{ label: '名称', field: 'name' }],
		formModel: { name: '' },
	},
	{
		type: 'SwitchNode',
		text: '切换',
		content: '根据script函数来确认要走那条边线',
		icon: svgU + 'switch.svg',
		formList: [
			{ label: '名称', field: 'name' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '脚本', field: 'script', type: 'javascript', javaScriptFunName: 'Switch' },
		],
		formModel: { name: '切换', debugMode: !1 },
	},
	{
		type: 'ScriptFilterNode',
		text: '函数',
		content: '对输入的消息msg进行JavaScript函数处理。返回处理后的结果。',
		icon: svgU + 'function.svg',
		formList: [
			{ label: '名称', field: 'name', rules: '' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '脚本', field: 'script', type: 'javascript', javaScriptFunName: 'Filter' },
		],
		formModel: { name: '函数', debugMode: !1, script: '' },
	},
	{
		type: 'MessageTypeSwitchNode',
		text: '消息类型切换',
		content: '根据设备类型选择走那条边线。',
		icon: svgU + 'msg.svg',
		formList: [
			{ label: '名称', field: 'name', rules: '' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
		],
		formModel: { name: '调试模式', debugMode: !1 },
	},
	{
		type: 'DeleteKeyNode',
		text: '删除键',
		content: '删除msg中的key',
		icon: svgU + 'fetch.svg',
		formList: [
			{ label: '名称', field: 'name', rules: '' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{
				label: '键类型',
				field: 'formType',
				type: 'radio',
				options: {
					data: [
						{ label: 'Msg', value: 'msg' },
						{ label: 'Metadata', value: 'metadata' },
					],
				},
			},
			{ label: '设置键', field: 'keys', type: 'multiple', rules: '' },
		],
		formModel: { name: '删除键', debugMode: !1, formType: 'msg', keys: '' },
	},
	{
		type: 'RenameKeyNode',
		text: '重命名键',
		content: '重命名msg消息中的key',
		icon: svgU + 'renamekey.svg',
		formList: [
			{ label: '名称', field: 'name', rules: '' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{
				label: '键类型',
				field: 'formType',
				type: 'radio',
				options: {
					data: [
						{ label: 'Msg', value: 'msg' },
						{ label: 'Metadata', value: 'metadata' },
					],
				},
			},
			{ label: '设置键', field: 'keys', type: 'object', key: '重命名键', value: '新键' },
		],
		formModel: { name: '重命名键', debugMode: !1, formType: 'msg', keys: [{ oldName: '', newName: '' }] },
	},

	{
		type: 'ScriptKeyNode',
		text: '函数键',
		content: '通过script函数来操作msg中的key',
		icon: svgU + 'exec.svg',
		formList: [
			{ label: '名称', field: 'name', rules: '' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '脚本', field: 'script', type: 'javascript', javaScriptFunName: 'Transform' },
		],
		formModel: { name: '函数键', debugMode: !1, script: '' },
	},
	{
		type: 'MqttNode',
		text: 'Mqtt',
		content: '消息发送到MQTT',
		icon: svgU + 'mqtt.png',
		formList: [
			{ label: '名称', field: 'name', rules: '' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '主题模式', field: 'topicPattern', rules: '' },
			{ label: '主机地址', field: 'host', rules: '' },
			{ label: '端口号', field: 'port', rules: '' },
			{ label: '连接超时(秒)', field: 'connectTimeoutSec', type: 'number', rules: '' },
			{ label: '用户名', field: 'username', rules: '' },
			{ label: '密码', field: 'password', rules: '' },
			{ label: '客户端ID', field: 'clientId' },
			{ label: '清除缓存', field: 'cleanSession', type: 'checkbox' },
			{ label: '是否开启SSL', field: 'ssl', type: 'checkbox' },
		],
		formModel: {
			name: 'Mqtt',
			debugMode: !1,
			topicPattern: 'my-topic',
			host: '',
			port: '1883',
			connectTimeoutSec: 10,
			username: '',
			password: '',
			clientId: '',
			cleanSession: !0,
			ssl: !1,
		},
	},

	{
		type: 'DingNode',
		text: '钉钉',
		content: '消息发送到钉钉机器人',
		icon: svgU + 'ding.svg',
		formList: [
			{ label: '名称', field: 'name', rules: '' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: 'WebHook', field: 'webHook', rules: '' },
			{ label: '密钥', field: 'secret', rules: '' },
			{ label: '发送内容', field: 'content', type: 'textarea', rules: '' },
			{ label: '@所有人', field: 'isAtAll', type: 'checkbox' },
			{ label: '单独发送', field: 'atMobiles', type: 'select', options: {}, multiple: !0 },
		],
		formModel: { name: '钉钉', debugMode: !1, webHook: '', secret: '', content: '', isAtAll: !1, atMobiles: [] },
	},
	{
		type: 'WechatNode',
		text: '企业微信',
		content: '消息发送到企业微信机器人',
		icon: svgU + 'wechat.svg',
		formList: [
			{ label: '名称', field: 'name', rules: '' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: 'WebHook', field: 'webHook', rules: '' },
			{ label: '发送内容', field: 'content', type: 'textarea', rules: '' },
			{ label: '@所有人', field: 'isAtAll', type: 'checkbox' },
			{ label: '单独发送', field: 'atMobiles', type: 'select', options: {}, multiple: !0 },
		],
		formModel: { name: '企业微信', debugMode: !1, webHook: '', content: '', isAtAll: !1, atMobiles: [] },
	},

	{
		type: 'HttpNode',
		text: '接口请求',
		content: '消息发送到rest api接口',
		icon: svgU + 'api.svg',
		formList: [
			{ label: '名称', field: 'name', rules: '' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '请求URL', field: 'restEndpointUrlPattern', rules: '' },
			{ label: '请求方法', field: 'requestMethod', type: 'select', options: {} },
			{ label: '请求头', field: 'headers', type: 'attribute', key: 'Header', value: 'Value' },
			{ label: '读取超时', field: 'readTimeoutMs', type: 'number' },
			{ label: '最大请求数', field: 'maxParallelRequestsCount', type: 'number' },
			{ label: '消息持久化', field: 'useRedisQueueForMsgPersistence', type: 'checkbox' },
			{ label: '队列大小', field: 'maxQueueSize', type: 'number', vif: 'useRedisQueueForMsgPersistence' },
		],
		formModel: {
			name: '接口请求',
			debugMode: !1,
			restEndpointUrlPattern: 'http://localhost/api',
			requestMethod: 'post',
			headers: { 'Content-Type': 'application/json' },
			readTimeoutMs: 0,
			maxParallelRequestsCount: 0,
			useRedisQueueForMsgPersistence: !1,
			trimQueue: '',
			maxQueueSize: 0,
		},
	},

	{
		type: 'EmailNode',
		text: '邮件',
		content: '消息发送到Email',
		icon: svgU + 'email.svg',
		formList: [
			{ label: '名称', field: 'name', rules: '' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '收件人', field: 'to', rules: '' },
			{ label: '主题', field: 'subject', rules: '' },
			{ label: '内容', field: 'body', type: 'textarea', rules: '' },
		],
		formModel: {
			name: '邮件',
			debugMode: !1,
			to: '{{.userEmail}}',
			subject: 'Device {{.deviceType}} temperature high',
			body: 'Device {{.deviceName}} has high temperature {{.temp}}',
		},
	},

	{
		type: 'KafkaNode',
		text: 'Kafka',
		content: '消息发送到Kafka消息队列',
		icon: svgU + 'kafka.svg',
		formList: [
			{ label: '名称', field: 'name', rules: 'at' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '服务', field: 'server', rules: 'at' },
			{ label: 'topic', field: 'topic', rules: 'at' },
			{ label: '键类型', field: 'keyPattern', type: 'select', options: '_b', rules: 'Ad' },
			{ label: '最大发送数', field: 'producesBatchSize', type: 'number', rules: 'at' },
			{ label: '其它属性', field: 'otherProperties', type: 'attribute', key: '键', value: '值' },
		],
		formModel: { name: 'Kafka', debugMode: !1, server: '', topic: '', keyPattern: 'metadataKey', producesBatchSize: 16384, otherProperties: {} },
	},

	{
		type: 'NatsNode',
		text: 'Nats消息队列',
		content: '消息发送到nats消息队列',
		icon: svgU + 'nats.svg',
		formList: [
			{ label: '名称', field: 'name', rules: 'at' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '服务', field: 'server', rules: 'at' },
			{ label: 'topic', field: 'topic', rules: 'at' },
			{ label: '键类型', field: 'keyPattern', type: 'select', options: '_b', rules: 'Ad' },
			{ label: '其它属性', field: 'otherProperties', type: 'attribute', key: '键', value: '值' },
		],
		formModel: { name: 'Nats消息队列', debugMode: !1, server: '', topic: '', keyPattern: 'metadataKey', otherProperties: {} },
	},

	{
		type: 'SmsNode',
		text: '发送短信',
		content: '消息发送到短信',
		icon: svgU + 'sms.svg',
		formList: [
			{ label: '名称', field: 'name', rules: 'at' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
		],
		formModel: { name: '发送短信', debugMode: !1 },
	},
	{
		type: 'CreateAlarmNode',
		text: '创建告警',
		content: '根据条件创建告警信息',
		icon: svgU + 'alarm.svg',
		formList: [
			{ label: '名称', field: 'name', rules: 'at' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '报警类型', field: 'alarmType', type: 'input', rules: 'at' },
			{ label: '报警等级', field: 'alarmSeverity', type: 'select', options: 'G5', rules: 'Ad' },
		],
		formModel: { name: '创建告警', debugMode: !1, alarmType: 'General Alarm', alarmSeverity: 40 },
	},

	{
		type: 'ClearAlarmNode',
		text: '清除告警',
		content: '清除告警信息',
		icon: svgU + 'dalarm.svg',
		formList: [
			{ label: '名称', field: 'name', rules: 'at' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '报警等级', field: 'alarmType', type: 'input', rules: 'at' },
		],
		formModel: { name: '创建告警', debugMode: !1, alarmType: 'General Alarm' },
	},

	{
		type: 'DelayNode',
		text: '延时执行',
		content: '流程延时处理',
		icon: svgU + 'delay.svg',
		formList: [
			{ label: '名称', field: 'name', rules: 'at' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '周期(秒)', field: 'periodTs', type: 'number', rules: 'at' },
			{ label: '最大队列数', field: 'maxPendingMessages', type: 'number', rules: 'at' },
		],
		formModel: { name: '延时执行', debugMode: !1, periodTs: 60, maxPendingMessages: 1e3 },
	},

	{
		type: 'LogNode',
		text: '日志节点',
		content: '打印运行日志',
		icon: svgU + 'log.svg',
		formList: [
			{ label: '名称', field: 'name', rules: 'at' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '', field: 'script', type: 'javascript', javaScriptFunName: 'ToString' },
		],
		formModel: { name: '日志节点', debugMode: !1, script: '$5' },
	},

	{
		type: 'SaveAttributesNode',
		text: '保存参数',
		content: '将上传的设备参数信息保存',
		icon: svgU + 'attributes.svg',
		formList: [
			{ label: '名称', field: 'name', rules: '' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
		],
		formModel: { name: '保存参数', debugMode: !1 },
	},

	{
		type: 'SaveTimeSeriesNode',
		text: '保存遥测',
		content: '将上传的设备遥测信息保存',
		icon: svgU + 'json.svg',
		formList: [
			{ label: '名称', field: 'name', rules: 'at' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
		],
		formModel: { name: '保存遥测', debugMode: !1 },
	},

	{
		type: 'RpcRequestFromDeviceNode',
		text: '设备RPC请求',
		content: '处理设备端调用服务端的功能，例如过去服务器时间',
		icon: svgU + 'rpcresp.svg',
		formList: [
			{ label: '名称', field: 'name', rules: 'at' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '请求ID', type: 'number', field: 'requestId' },
		],
		formModel: { name: 'RPC回复', debugMode: !1 },
	},

	{
		type: 'RpcRequestToDeviceNode',
		text: '服务RPC下发',
		content: '调用设备端功能，例如远程开关',
		icon: svgU + 'rpcreq.svg',
		formList: [
			{ label: '名称', field: 'name', rules: 'at' },
			{ label: '调试模式', field: 'debugMode', type: 'switch' },
			{ label: '超时时间', type: 'number', field: 'timeout' },
		],
		formModel: { name: 'RPC调用', debugMode: !1, timeout: 0, payload: 'U5' },
	},
];
